<!DOCTYPE html>
<html>
<head>
	<title>test repo</title>
</head>
<body>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<input type="button" value="test_get" onclick="test_get()" />
<input type="button" value="test_create" onclick="test_create()" />
<input type="button" value="test_update" onclick="test_update()" />
<input type="button" value="test_delete" onclick="test_delete()" />
<input type="button" value="test_list" onclick="test_list()" />
<input type="button" value="test_delivery_list" onclick="test_delivery_list()" />
<script>


    function test_list() {
        $.ajax({
            type: "POST",
            url: "http://127.0.0.1:9912/event/search",
            dataType: "json",
            headers: {'Content-Type': 'application/json'},
            data: JSON.stringify({
                "order" : {
                        "field" : "id",
                        "order" : "desc"
               } ,
               "offset" : 0,
               "max" : 3,
               "query": {
                   "and" : [
                        {
                            "field" : "id",
                            "value" : 1,
                            "op" : "="
                        }]
               }
            }),
            success: function (data) {
               alert(data)
            }
        })
    }

        function test_delivery_list() {
        $.ajax({
            type: "POST",
            url: "/v1/delivery/search?sessionId=12345678",
            dataType: "json",
            headers: {'Content-Type': 'application/json'},
            data: JSON.stringify({
                    "order" : {
                            "field" : "created",
                            "order" : "desc"
                   } ,
                   "offset" : 0,
                   "max" : 3,
                   "query": {
                       "and" : [
                            {
                                "field" : "d.id",
                                "value" : 1,
                                "op" : "="
                            }]
                   }
            }),
            success: function (data) {
               alert(data)
            }
        })
    }

    function test_create() {
        $.ajax({
            type: "POST",
            url: "/v1/repo?sessionId=12345678",
            dataType: "json",
            headers: {'Content-Type': 'application/json'},
            data: JSON.stringify({
                name: "仓库11",
                ParentId: 1,
                LocationType: 0,
                Note: "test repo",
                DefaultInAction: 1,
                DefaultInActionName: "入库",
                DefaultOutAction: 0,
                DefaultOutActionName: "出库",
                Attrs: {"Id": 1, "ContactInfo": {"email2": "xx@yy.com", "phone2": "2223334444"}}
            }),
            success: function (data) {
               alert(data)
            }
        })
    }

    function test_update() {
        $.ajax({
            type: "PUT",
            url: "/v1/repo/10?sessionId=12345678",
            dataType: "json",
            headers: {'Content-Type': 'application/json'},
            data: JSON.stringify({
                name: "仓库8a",
                ParentId: 0,
                LocationType: 0,
                Note: "test repo",
                DefaultInAction: 1,
                DefaultInActionName: "入库",
                DefaultOutAction: 0,
                DefaultOutActionName: "出库",
                Attrs: {"Id": 1, "ContactInfo": {"emai32": "xx@yy.com", "phone1": "2223334444"}}
            }),
            success: function (data) {
               alert(data.data.total)
            }
        })
    }

    function test_delete() {
        $.ajax({
            type: "DELETE",
            url: "/v1/repo/9?sessionId=12345678",
            success: function (data) {
               alert(data.data.total)
            }
        })
    }
</script>
</body>
</html>